﻿namespace AnyOffice.WorkFlowRegex
{
    using ADOGuy;
    using log4net;
    using Microsoft.VisualBasic;
    using System;
    using System.Collections;
    using System.Data;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Web;
    using System.Reflection;

    public class FormRegex
    {
        private string _autoItem = string.Empty;
        private string _formName = string.Empty;
        private string _hiddenItem = string.Empty;
        private string _htmlResult = string.Empty;
        private string _htmlSource = string.Empty;
        private bool _isFixedFlow = true;
        private Hashtable _prcsUser1 = new Hashtable();
        private Hashtable _prcsUser2 = new Hashtable();
        private string _processItem = string.Empty;
        private int _runId = 0;
        private string _runName = string.Empty;
        private ArrayList _title = new ArrayList();
        private ArrayList _value = new ArrayList();
        private ArrayList arrayList = new ArrayList();
        private DateTime dtNow = DateTime.Now;
        private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public bool CheckPrcsIn(string prcsIn, string prcsInSet, string zbFeedback, string cbFeedback, string publicAttachment, ref string message)
        {
            return this.CheckPrcsOut(prcsIn, prcsInSet, zbFeedback, cbFeedback, publicAttachment, ref message);
        }

        public bool CheckPrcsOut(string prcsOut, string prcsOutSet, string zbFeedback, string cbFeedback, string publicAttachment, ref string message)
        {
            if (prcsOut == string.Empty) return true;
            bool flag = true;
            try
            {
                if (prcsOut.EndsWith("\n")) prcsOut = prcsOut.Substring(0, prcsOut.Length - 1);
                prcsOut = prcsOut.Replace("\r", "");
                string[] strArray = prcsOut.Split(new char[] { '\n' });
                DataTable table = new DataTable();
                table.Columns.Add("Expression", Type.GetType("System.String"));
                table.Columns.Add("Result", Type.GetType("System.Boolean"));
                table.Columns.Add("Message", Type.GetType("System.String"));
                for (int i = 0; i < strArray.Length; i++)
                {
                    table.Rows.Add(new object[] { "", false, "" });
                }
                string pattern = @"'(?<aaa>\S+)'(?<action>\S*)'(?<bbb>\S*)'";
                if (strArray.Length <= 0) return flag;
                for (int j = 0; j < strArray.Length; j++)
                {
                    string str4;
                    Match match = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(strArray[j]);
                    if (!match.Success) continue;
                    table.Rows[j]["Expression"] = match.Value;
                    if (!match.Groups["aaa"].Success || !match.Groups["action"].Success || !match.Groups["bbb"].Success) continue;
                    string str5 = match.Groups["aaa"].ToString();
                    string expression = match.Groups["bbb"].ToString();
                    string str3 = string.Empty;
                    for (int m = 0; m < this._title.Count; m++)
                    {
                        if (str5 == this._title[m].ToString() && m < this.arrayList.Count) str3 = this.arrayList[m].ToString();
                    }
                    string str7 = str5;
                    if (str7 != null)
                    {
                        if (!(str7 == "[主办人会签意见]"))
                        {
                            if (str7 == "[从办人会签意见]") goto Label_02B0;
                            if (str7 == "[公共附件名称]") goto Label_02B6;
                        }
                        else
                            str3 = zbFeedback;
                    }
                    goto Label_02BC;
                Label_02B0:
                    str3 = cbFeedback;
                    goto Label_02BC;
                Label_02B6:
                    str3 = publicAttachment;
                Label_02BC:
                    if (Information.IsNumeric(expression))
                        str4 = "Numeric";
                    else if (Information.IsDate(expression))
                        str4 = "Date";
                    else
                        str4 = "String";
                    switch (match.Groups["action"].Value.ToLower())
                    {
                        case "=":
                        {
                            table.Rows[j]["Message"] = str5 + " 等于 " + this.GetEmpty(expression);
                            switch (str4)
                            {
                                case "Date":
                                    goto Label_04D1;

                                case "String":
                                    goto Label_051B;
                            }
                            continue;
                        }
                        case "<>":
                        {
                            table.Rows[j]["Message"] = str5 + " 不等于 " + this.GetEmpty(expression);
                            switch (str4)
                            {
                                case "Numeric":
                                    goto Label_05BE;

                                case "Date":
                                    goto Label_0608;

                                case "String":
                                    goto Label_0652;
                            }
                            continue;
                        }
                        case ">":
                        {
                            table.Rows[j]["Message"] = str5 + " 大于 " + this.GetEmpty(expression);
                            switch (str4)
                            {
                                case "Numeric":
                                    goto Label_06E4;

                                case "Date":
                                    goto Label_072E;
                            }
                            continue;
                        }
                        case "<":
                        {
                            table.Rows[j]["Message"] = str5 + " 小于 " + this.GetEmpty(expression);
                            switch (str4)
                            {
                                case "Numeric":
                                    goto Label_07D6;

                                case "Date":
                                    goto Label_0820;
                            }
                            continue;
                        }
                        case ">=":
                        {
                            table.Rows[j]["Message"] = str5 + " 大于等于 " + this.GetEmpty(expression);
                            switch (str4)
                            {
                                case "Numeric":
                                    goto Label_08C8;

                                case "Date":
                                    goto Label_0912;
                            }
                            continue;
                        }
                        case "<=":
                        {
                            table.Rows[j]["Message"] = str5 + " 小于等于 " + this.GetEmpty(expression);
                            switch (str4)
                            {
                                case "Numeric":
                                    goto Label_09BA;

                                case "Date":
                                    goto Label_0A04;
                            }
                            continue;
                        }
                        case "include":
                        {
                            table.Rows[j]["Message"] = str5 + " 包含 " + this.GetEmpty(expression);
                            if (str3.IndexOf(expression) > -1) table.Rows[j]["Result"] = true;
                            continue;
                        }
                        case "exclude":
                        {
                            table.Rows[j]["Message"] = str5 + " 不包含 " + this.GetEmpty(expression);
                            if (str3.IndexOf(expression) == -1) table.Rows[j]["Result"] = true;
                            continue;
                        }
                        case "startwith":
                        {
                            table.Rows[j]["Message"] = str5 + " 开始为 " + this.GetEmpty(expression);
                            if (str3.StartsWith(expression)) table.Rows[j]["Result"] = true;
                            continue;
                        }
                        case "endwith":
                        {
                            table.Rows[j]["Message"] = str5 + " 结束为 " + this.GetEmpty(expression);
                            if (str3.EndsWith(expression)) table.Rows[j]["Result"] = true;
                            continue;
                        }
                        case "==":
                        {
                            table.Rows[j]["Message"] = str5 + " 类型等于 " + expression;
                            switch (expression)
                            {
                                case "数值":
                                    goto Label_0C4A;

                                case "日期":
                                    goto Label_0C7F;

                                case "日期+时间":
                                    goto Label_0CC1;
                            }
                            continue;
                        }
                        case "!==":
                        {
                            table.Rows[j]["Message"] = str5 + " 类型不等于 " + expression;
                            switch (expression)
                            {
                                case "数值":
                                    goto Label_0D69;

                                case "日期":
                                    goto Label_0D98;

                                case "日期+时间":
                                    goto Label_0DD7;
                            }
                            continue;
                        }
                        default:
                        {
                            continue;
                        }
                    }
                    if (Information.IsNumeric(str3) && Convert.ToDecimal(str3) == Convert.ToDecimal(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_04D1:
                    if (Information.IsDate(str3) && Convert.ToDateTime(str3) == Convert.ToDateTime(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_051B:
                    if (str3 == expression) table.Rows[j]["Result"] = true;
                    continue;
                Label_05BE:
                    if (Information.IsNumeric(str3) && Convert.ToDecimal(str3) != Convert.ToDecimal(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_0608:
                    if (Information.IsDate(str3) && Convert.ToDateTime(str3) != Convert.ToDateTime(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_0652:
                    if (str3 != expression) table.Rows[j]["Result"] = true;
                    continue;
                Label_06E4:
                    if (Information.IsNumeric(str3) && Convert.ToDecimal(str3) > Convert.ToDecimal(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_072E:
                    if (Information.IsDate(str3) && Convert.ToDateTime(str3) > Convert.ToDateTime(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_07D6:
                    if (Information.IsNumeric(str3) && Convert.ToDecimal(str3) < Convert.ToDecimal(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_0820:
                    if (Information.IsDate(str3) && Convert.ToDateTime(str3) < Convert.ToDateTime(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_08C8:
                    if (Information.IsNumeric(str3) && Convert.ToDecimal(str3) >= Convert.ToDecimal(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_0912:
                    if (Information.IsDate(str3) && Convert.ToDateTime(str3) >= Convert.ToDateTime(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_09BA:
                    if (Information.IsNumeric(str3) && Convert.ToDecimal(str3) <= Convert.ToDecimal(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_0A04:
                    if (Information.IsDate(str3) && Convert.ToDateTime(str3) <= Convert.ToDateTime(expression)) table.Rows[j]["Result"] = true;
                    continue;
                Label_0C4A:
                    if (Information.IsNumeric(str3)) table.Rows[j]["Result"] = true;
                    continue;
                Label_0C7F:
                    if (Information.IsDate(str3) && str3.Length < 11) table.Rows[j]["Result"] = true;
                    continue;
                Label_0CC1:
                    if (Information.IsDate(str3) && str3.Length > 10) table.Rows[j]["Result"] = true;
                    continue;
                Label_0D69:
                    if (!Information.IsNumeric(str3)) table.Rows[j]["Result"] = true;
                    continue;
                Label_0D98:
                    if (!Information.IsDate(str3) || str3.Length >= 11) table.Rows[j]["Result"] = true;
                    continue;
                Label_0DD7:
                    if (!Information.IsDate(str3) || str3.Length <= 10) table.Rows[j]["Result"] = true;
                }
                if (prcsOutSet == string.Empty)
                {
                    for (int n = 0; n < table.Rows.Count; n++)
                    {
                        if (!Convert.ToBoolean(table.Rows[n]["Result"].ToString()))
                        {
                            flag = false;
                            message = message + table.Rows[n]["Message"].ToString() + "\n";
                            message = "不符合条件：" + message;
                        }
                    }
                    return flag;
                }
                string str6 = prcsOutSet;
                prcsOutSet = VBString.Replace(prcsOutSet, "and", "&&");
                prcsOutSet = VBString.Replace(prcsOutSet, "or", "||");
                for (int k = 0; k < table.Rows.Count; k++)
                {
                    if (prcsOutSet.IndexOf("[" + Convert.ToString((int) (k + 1)) + "]") > -1) prcsOutSet = prcsOutSet.Replace("[" + Convert.ToString((int) (k + 1)) + "]", table.Rows[k]["Result"].ToString().ToLower());
                }
                pattern = @"(?<Find>\[\d*\])";
                prcsOutSet = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase).Replace(prcsOutSet, "true");
                try
                {
                    if (!Evaluator.EvaluateToBool(prcsOutSet))
                    {
                        flag = false;
                        message = str6;
                        for (int num6 = 0; num6 < table.Rows.Count; num6++)
                        {
                            if (message.IndexOf("[" + Convert.ToString((int) (num6 + 1)) + "]") > -1) message = message.Replace("[" + Convert.ToString((int) (num6 + 1)) + "]", "[" + table.Rows[num6]["Message"].ToString() + "]");
                        }
                        message = message.Replace("!", " 非 ");
                        message = "不符合条件公式：" + message;
                    }
                    return flag;
                }
                catch (Exception exception)
                {
                    flag = true;
                    message = "条件公式分析出错";
                    if (log.IsErrorEnabled) { log.Error("", exception); }
                    return flag;
                }
            }
            catch (Exception exception2)
            {
                if (log.IsErrorEnabled) { log.Error("", exception2); }
            }
            return flag;
        }

        public DataTable GetControlBaseAttribute()
        {
            DataTable table = new DataTable();
            table.Columns.Add("Sequence", Type.GetType("System.Int32"));
            table.Columns.Add("Title", Type.GetType("System.String"));
            table.Columns.Add("ControlType", Type.GetType("System.Int32"));
            table.Columns.Add("DataFld", Type.GetType("System.String"));
            table.Columns.Add("LV_TITLE", Type.GetType("System.String"));
            string str = "<(?<Tag>input)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>";
            Match match = new Regex(str + "|<(?<Tag>textarea)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?<Value>(?:.|\\n)*?)</textarea>|<(?<Tag>select)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?:.|\\n)*?</select>|<(?<Tag>IMG)[^>]*?class=LIST_VIEW[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>", RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(this._htmlSource);
            int num = 1;
            while (match.Success)
            {
                if (match.Groups["Tag"].Success && match.Groups["Title"].Success)
                {
                    FormControl control = new FormControl {
                        Source = match.Value.ToUpper(),
                        Tag = match.Groups["Tag"].Value.ToUpper(),
                        Title = match.Groups["Title"].Value,
                        Sequence = num
                    };
                    control.BaseAttributeAnalyze();
                    table.Rows.Add(new object[] { num, control.Title, (int) control.ControlType, control.DataFld, control.LvTitle });
                    num++;
                }
                match = match.NextMatch();
            }
            return table;
        }

        private string GetEmpty(string str)
        {
            if (str == string.Empty) return "空";
            return str;
        }

        public string GetHtmlAnalyze()
        {
            FormControl control;
            string pattern = "<(?<Tag>input)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>";
            Match match = new Regex(pattern + "|<(?<Tag>textarea)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?<Value>(?:.|\\n)*?)</textarea>|<(?<Tag>select)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?:.|\\n)*?</select>|<(?<Tag>IMG)[^>]*?class=LIST_VIEW[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>", RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(this._htmlSource);
            this._title.Clear();
            this._value.Clear();
            int num = 1;
            int startIndex = 0;
            int index = 0;
            HttpResponse response = HttpContext.Current.Response;
            StringBuilder builder = new StringBuilder();
            while (match.Success)
            {
                index = match.Index;
                builder.Append(this._htmlSource.Substring(startIndex, index - startIndex));
                startIndex = match.Index + match.Length;
                if (match.Groups["Tag"].Success && match.Groups["Title"].Success)
                {
                    this._title.Add(match.Groups["Title"].Value);
                    control = new FormControl {
                        Source = match.Value.ToUpper(),
                        Tag = match.Groups["Tag"].Value.ToUpper(),
                        Title = match.Groups["Title"].Value,
                        Sequence = num,
                        PrcsUser1 = this._prcsUser1,
                        PrcsUser2 = this._prcsUser2,
                        FormName = this._formName,
                        RunId = this._runId,
                        RunName = this._runName
                    };
                    if (this.arrayList.Count > num - 1) control.SetValue = this.arrayList[num - 1].ToString();
                    if (this._isFixedFlow)
                    {
                        if (this._processItem.IndexOf("," + control.Title + ",") > -1)
                            control.ReadOnly = false;
                        else
                            control.ReadOnly = true;
                        if (this._autoItem.IndexOf("," + control.Title + ",") > -1)
                            control.AutoMacro = true;
                        else
                            control.AutoMacro = false;
                        if (this._hiddenItem.IndexOf("," + control.Title + ",") > -1)
                            control.Hidden = true;
                        else
                            control.Hidden = false;
                    }
                    else
                        control.ReadOnly = false;
                    builder.Append(control.HtmlAnalyze());
                    num++;
                }
                else
                    builder.Append(match.Value);
                match = match.NextMatch();
            }
            builder.Append(this._htmlSource.Substring(startIndex));
            this._htmlSource = builder.Replace("#[表单]", this._formName).Replace("#[文号]", this._runName).Replace("#[时间]", "日期：" + this.dtNow.ToString("D")).ToString();
            builder = new StringBuilder();
            pattern = "<(?<Tag>INPUT)[^>]*?class=CALC[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?\\svalue=(?:(?<value>[^\\s\"'>]+)|(?<value>\\w+)|\"(?<value>.*?)\"|\\'(?<value>.*?)\\')[^>]*?>";
            pattern = pattern + "|<(?<Tag>IMG)[^>]*?class=DATE[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?\\svalue=(?:(?<value>[^\\s\"'>]+)|(?<value>\\w+)|\"(?<value>.*?)\"|\\'(?<value>.*?)\\')[^>]*?>|<(?<Tag>IMG)[^>]*?class=USER[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?\\svalue=(?:(?<value>[^\\s\"'>]+)|(?<value>\\w+)|\"(?<value>.*?)\"|\\'(?<value>.*?)\\')[^>]*?>";
            startIndex = 0;
            index = 0;
            Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            for (match = regex.Match(this._htmlSource); match.Success; match = match.NextMatch())
            {
                index = match.Index;
                builder.Append(this._htmlSource.Substring(startIndex, index - startIndex));
                startIndex = match.Index + match.Length;
                if (match.Groups["Tag"].Success && match.Groups["Title"].Success)
                {
                    control = new FormControl {
                        Source = match.Value.ToUpper(),
                        Tag = match.Groups["Tag"].Value.ToUpper(),
                        Title = match.Groups["Title"].Value
                    };
                    builder.Append(control.DataOrCalculate(this._title, this._processItem, this._isFixedFlow));
                }
                else
                    builder.Append(match.Value);
            }
            builder.Append(this._htmlSource.Substring(startIndex));
            this._htmlSource = builder.ToString();
            this._htmlResult = this._htmlSource;
            return this._htmlResult;
        }

        public DataTable GetHtmlQuery()
        {
            DataTable table = new DataTable();
            table.Columns.Add("Sequence", Type.GetType("System.Int32"));
            table.Columns.Add("Title", Type.GetType("System.String"));
            table.Columns.Add("Relation", Type.GetType("System.String"));
            table.Columns.Add("Data", Type.GetType("System.String"));
            string str = "<(?<Tag>input)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>";
            Match match = new Regex(str + "|<(?<Tag>textarea)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?<Value>(?:.|\\n)*?)</textarea>|<(?<Tag>select)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?:.|\\n)*?</select>|<(?<Tag>IMG)[^>]*?class=LIST_VIEW[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>", RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(this._htmlSource);
            int num = 1;
            while (match.Success)
            {
                if (!(match.Groups["Tag"].Success && match.Groups["Title"].Success)) goto Label_03D5;
                FormControl control = new FormControl {
                    Source = match.Value.ToUpper(),
                    Tag = match.Groups["Tag"].Value.ToUpper(),
                    Title = match.Groups["Title"].Value,
                    Sequence = num
                };
                try
                {
                    control.HtmlQuery();
                }
                catch (Exception exception)
                {
                    if (log.IsErrorEnabled) { log.Error("", exception); }
                }
                DataRow row = table.NewRow();
                row["Sequence"] = num;
                row["Title"] = control.Title;
                StringBuilder builder = new StringBuilder();
                switch (control.ControlType)
                {
                    case ControlType.Input:
                    case ControlType.TextArea:
                    case ControlType.ListView:
                    case ControlType.MacroInput:
                    case ControlType.Calculate:
                        builder.Append("<select name=\"RELATION_" + num.ToString() + "\" class=\"SmallSelect\">\n");
                        builder.Append("\t<option value=\"=\">等于</option>\n");
                        builder.Append("\t<option value=\">\">大于</option>\n");
                        builder.Append("\t<option value=\"<\">小于</option>\n");
                        builder.Append("\t<option value=\">=\">大于等于</option>\n");
                        builder.Append("\t<option value=\"<=\">小于等于</option>\n");
                        builder.Append("\t<option value=\"<>\">不等于</option>\n");
                        builder.Append("\t<option value=\"STARTWITH\">开始为</option>\n");
                        builder.Append("\t<option value=\"INDEXOF\" selected>包含</option>\n");
                        builder.Append("\t<option value=\"ENDWITH\">结束为</option>\n");
                        builder.Append("</select>\n");
                        row["Relation"] = builder.ToString();
                        goto Label_03AF;

                    case ControlType.Select:
                    case ControlType.Checkbox:
                    case ControlType.MacroSelect:
                        if (control.DataFld.ToUpper() != "SYS_LIST_SQL") break;
                        goto Label_02FB;

                    default:
                        goto Label_03AF;
                }
                builder.Append("<select name=\"RELATION_" + num.ToString() + "\" class=\"SmallSelect\">\n");
                builder.Append("\t<option value=\"=\">等于</option>\n");
                builder.Append("</select>\n");
                goto Label_039B;
            Label_02FB:
                builder.Append("<select name=\"RELATION_" + num.ToString() + "\" class=\"SmallSelect\">\n");
                builder.Append("\t<option value=\"=\">等于</option>\n");
                builder.Append("\t<option value=\">\">大于</option>\n");
                builder.Append("\t<option value=\"<\">小于</option>\n");
                builder.Append("\t<option value=\">=\">大于等于</option>\n");
                builder.Append("\t<option value=\"<=\">小于等于</option>\n");
                builder.Append("\t<option value=\"<>\">不等于</option>\n");
                builder.Append("\t<option value=\"STARTWITH\">开始为</option>\n");
                builder.Append("\t<option value=\"INDEXOF\" selected>包含</option>\n");
                builder.Append("\t<option value=\"ENDWITH\">结束为</option>\n");
                builder.Append("</select>\n");
            Label_039B:
                row["Relation"] = builder.ToString();
            Label_03AF:
                row["Data"] = control.Result;
                table.Rows.Add(row);
                num++;
            Label_03D5:
                match = match.NextMatch();
            }
            return table;
        }

        public string GetHtmlView()
        {
            string pattern = "<(?<Tag>input)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>";
            pattern = pattern + "|<(?<Tag>textarea)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?<Value>(?:.|\\n)*?)</textarea>|<(?<Tag>select)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?:.|\\n)*?</select>|<(?<Tag>IMG)[^>]*?class=LIST_VIEW[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>";
            Match match = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(this._htmlSource);
            this._value.Clear();
            int num = 1;
            int startIndex = 0;
            int index = 0;
            StringBuilder builder = new StringBuilder();
            HttpResponse response = HttpContext.Current.Response;
            while (match.Success)
            {
                index = match.Index;
                builder.Append(this._htmlSource.Substring(startIndex, index - startIndex));
                startIndex = match.Index + match.Length;
                if (match.Groups["Tag"].Success && match.Groups["Title"].Success)
                {
                    FormControl control = new FormControl {
                        Source = match.Value.ToUpper(),
                        Tag = match.Groups["Tag"].Value.ToUpper(),
                        Title = match.Groups["Title"].Value,
                        Sequence = num,
                        PrcsUser1 = this._prcsUser1,
                        PrcsUser2 = this._prcsUser2,
                        FormName = this._formName,
                        RunId = this._runId,
                        RunName = this._runName
                    };
                    if (this.arrayList.Count > num - 1) control.SetValue = this.arrayList[num - 1].ToString();
                    if (this._hiddenItem.IndexOf("," + control.Title + ",") > -1)
                        control.Hidden = true;
                    else
                        control.Hidden = false;
                    builder.Append(control.HtmlView());
                    this._title.Add(match.Groups["Title"].Value);
                    num++;
                }
                else
                    builder.Append(match.Value);
                match = match.NextMatch();
            }
            builder.Append(this._htmlSource.Substring(startIndex));
            this._htmlSource = builder.ToString();
            this._htmlSource = builder.Replace("#[表单]", this._formName).Replace("#[文号]", this._runName).Replace("#[时间]", "日期：" + this.dtNow.ToString("D")).ToString();
            builder = new StringBuilder();
            pattern = pattern + "|<(?<Tag>IMG)[^>]*?class=DATE[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?\\svalue=(?:(?<value>[^\\s\"'>]+)|(?<value>\\w+)|\"(?<value>.*?)\"|\\'(?<value>.*?)\\')[^>]*?>";
            startIndex = 0;
            index = 0;
            Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            for (match = regex.Match(this._htmlSource); match.Success; match = match.NextMatch())
            {
                index = match.Index;
                builder.Append(this._htmlSource.Substring(startIndex, index - startIndex));
                startIndex = match.Index + match.Length;
            }
            builder.Append(this._htmlSource.Substring(startIndex));
            this._htmlSource = builder.ToString();
            this._htmlSource = builder.ToString();
            builder = new StringBuilder();
            pattern = pattern + "|<(?<Tag>IMG)[^>]*?class=USER[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?\\svalue=(?:(?<value>[^\\s\"'>]+)|(?<value>\\w+)|\"(?<value>.*?)\"|\\'(?<value>.*?)\\')[^>]*?>";
            startIndex = 0;
            index = 0;
            regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            for (match = regex.Match(this._htmlSource); match.Success; match = match.NextMatch())
            {
                index = match.Index;
                builder.Append(this._htmlSource.Substring(startIndex, index - startIndex));
                startIndex = match.Index + match.Length;
            }
            builder.Append(this._htmlSource.Substring(startIndex));
            this._htmlSource = builder.ToString();
            this._htmlResult = this._htmlSource;
            return this._htmlResult;
        }

        public ArrayList GetOriginalValue()
        {
            string str = "<(?<Tag>INPUT)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>";
            Match match = new Regex(str + "|<(?<Tag>TEXTAREA)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?<Value>(?:.|\\n)*?)</textarea>|<(?<Tag>select)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?:.|\\n)*?</select>|<(?<Tag>IMG)[^>]*?class=LIST_VIEW[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>", RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(this._htmlSource);
            int num = 0;
            HttpResponse response = HttpContext.Current.Response;
            string pattern = "\\svalue=(?:(?<Value>[^\\s\"'>]+)|(?<Value>{\\w+})|(?:\"(?<Value>.*?)\")|(?:\\'(?<Value>.*)\\'))";
            Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            this._value.Clear();
            while (match.Success)
            {
                int index = match.Index;
                int num3 = match.Index;
                int length = match.Length;
                if (match.Groups["Tag"].Success && match.Groups["Title"].Success)
                {
                    if (match.Groups["Tag"].Value.ToUpper() == "SELECT")
                        this._value.Add("");
                    else if (match.Groups["Tag"].Value.ToUpper() == "TEXTAREA")
                    {
                        if (match.Groups["Value"].Success)
                            this._value.Add(match.Groups["Value"].Value);
                        else
                            this._value.Add("");
                    }
                    else if (match.Groups["Tag"].Value.ToUpper() == "IMG")
                        this._value.Add("");
                    else
                    {
                        string input = VBString.Replace(match.Value, "class=CALC", "class=CALC");
                        Match match2 = regex.Match(input);
                        if (match2.Success && match2.Groups["Value"].Success && input.IndexOf("class=CALC") < 0)
                            this._value.Add(match2.Groups["Value"].Value);
                        else
                            this._value.Add("");
                    }
                }
                num++;
                match = match.NextMatch();
            }
            return this._value;
        }

        public ArrayList GetTitleValue()
        {
            string str = "<(?<Tag>INPUT)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>";
            Match match = new Regex(str + "|<(?<Tag>TEXTAREA)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?<Value>(?:.|\\n)*?)</textarea>|<(?<Tag>select)[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>(?:.|\\n)*?</select>|<(?<Tag>IMG)[^>]*?class=LIST_VIEW[^>]*?\\stitle=(?:(?<Title>[^\\s\"'>]+)|(?:\"(?<Title>.*?)\")|(?:\\'(?<Title>.*)\\'))[^>]*?>", RegexOptions.Compiled | RegexOptions.IgnoreCase).Match(this._htmlSource);
            HttpResponse response = HttpContext.Current.Response;
            this._title.Clear();
            while (match.Success)
            {
                if (match.Groups["Tag"].Success && match.Groups["Title"].Success) this._title.Add(match.Groups["Title"].Value);
                match = match.NextMatch();
            }
            return this._title;
        }

        public string AutoItem
        {
            get
            {
                return this._autoItem;
            }
            set
            {
                this._autoItem = "," + value + ",";
            }
        }

        public string FormName
        {
            get
            {
                return this._formName;
            }
            set
            {
                this._formName = value;
            }
        }

        public string HiddenItem
        {
            get
            {
                return this._hiddenItem;
            }
            set
            {
                this._hiddenItem = "," + value + ",";
            }
        }

        public string HtmlResult
        {
            get
            {
                return this._htmlResult;
            }
            set
            {
                this._htmlResult = value;
            }
        }

        public string HtmlSource
        {
            get
            {
                return this._htmlSource;
            }
            set
            {
                this._htmlSource = value;
            }
        }

        public bool IsFixedFlow
        {
            get
            {
                return this._isFixedFlow;
            }
            set
            {
                this._isFixedFlow = value;
            }
        }

        public Hashtable PrcsUser1
        {
            get
            {
                return this._prcsUser1;
            }
            set
            {
                this._prcsUser1 = value;
            }
        }

        public Hashtable PrcsUser2
        {
            get
            {
                return this._prcsUser2;
            }
            set
            {
                this._prcsUser2 = value;
            }
        }

        public string ProcessItem
        {
            get
            {
                return this._processItem;
            }
            set
            {
                this._processItem = "," + value + ",";
            }
        }

        public DateTime RunDateTime
        {
            get
            {
                return this.dtNow;
            }
            set
            {
                this.dtNow = value;
            }
        }

        public int RunId
        {
            get
            {
                return this._runId;
            }
            set
            {
                this._runId = value;
            }
        }

        public string RunName
        {
            get
            {
                return this._runName;
            }
            set
            {
                this._runName = value;
            }
        }

        public ArrayList SetValue
        {
            get
            {
                return this.arrayList;
            }
            set
            {
                this.arrayList = value;
            }
        }

        public ArrayList Title
        {
            get
            {
                return this._title;
            }
            set
            {
                this._title = value;
            }
        }

        public ArrayList Value
        {
            get
            {
                return this._value;
            }
            set
            {
                this._value = value;
            }
        }
    }
}

